import cv2
import numpy as np

img = cv2.imread('d:\\test\\messi5.jpg')
rows, cols, channels = img.shape

matrix = cv2.getRotationMatrix2D((cols / 2, rows / 2), 45, 0.6)

# dist = np.zeros((2, 3, 3), np.uint8)
# dist[0, 0] = 1
# dist[0, 2] = 20
# dist[1, 1] = 1
# dist[1, 2] = 10
points2 = np.float32([[1, 0, 100], [0, 1, 50]])

res = cv2.warpAffine(img, matrix, (cols, rows))

while (1):
    cv2.imshow('res', res)
    cv2.imshow('img', img)
    if cv2.waitKey(1) & 0xFF == 27:
        break
cv2.destroyAllWindows()
